import { useState, useEffect } from "react";
// debounce  防抖
export const useDebounce = (callback, value, delay) => {
  useEffect(() => {
    let timeout = setTimeout(() => {
      callback()
    }, delay);
    // 每次在上一个useEffect处理完成后才执行
    return () => {
      clearTimeout(timeout)
      console.log('useEffect被清理')
    }
  }, [value])
}